import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import '../helpers/magma_color.dart';
import '../helpers/magma_constant.dart';
import '../helpers/magma_text_style.dart';
import '../helpers/magma_tap.dart';

/// 加入俱乐部确认对话框
class JoinClubDialog {
  /// 显示加入俱乐部确认对话框
  static Future<bool?> show(BuildContext context, {required String clubName}) {
    return showDialog<bool>(
      context: context,
      barrierDismissible: true,
      builder: (context) => _JoinClubDialogContent(clubName: clubName),
    );
  }
}

/// 加入俱乐部对话框内容
class _JoinClubDialogContent extends StatelessWidget {
  final String clubName;

  const _JoinClubDialogContent({required this.clubName});

  @override
  Widget build(BuildContext context) {
    return Dialog(
      backgroundColor: Colors.transparent,
      child: Stack(
        clipBehavior: Clip.none,
        children: [
          // 主对话框内容
          Container(
            margin: EdgeInsets.only(top: 67.w),
            decoration: BoxDecoration(
              gradient: LinearGradient(
                begin: Alignment.topLeft,
                end: Alignment.bottomRight,
                colors: [Color(0xFFE8D5FF), Color(0xFFD0F4E6)],
              ),
              borderRadius: BorderRadius.circular(24.r),
            ),
            child: Padding(
              padding: EdgeInsets.fromLTRB(24.w, 80.h, 24.w, 24.h),
              child: Column(
                mainAxisSize: MainAxisSize.min,
                children: [
                  SizedBox(height: 20.h),
                  // 标题
                  Text(
                    'Are you sure you want\nto join this club?',
                    textAlign: TextAlign.center,
                  ).blackHanSans(
                    fontSize: 20.sp,
                    color: MagmaColor.black,
                    fontWeight: FontWeight.w700,
                  ),

                  SizedBox(height: 32.h),

                  // Join In 按钮
                  MagmaTap(
                    onTap: () => Navigator.of(context).pop(true),
                    child: Container(
                      width: double.infinity,
                      height: 56.h,
                      decoration: BoxDecoration(
                        color: MagmaColor.purple,
                        borderRadius: BorderRadius.circular(28.r),
                      ),
                      child: Center(
                        child: Text('Join In').blackHanSans(
                          fontSize: 20.sp,
                          color: MagmaColor.white,
                          fontWeight: FontWeight.w700,
                        ),
                      ),
                    ),
                  ),

                  SizedBox(height: 12.h),

                  // Cancel 按钮
                  MagmaTap(
                    onTap: () => Navigator.of(context).pop(false),
                    child: Container(
                      width: double.infinity,
                      height: 56.h,
                      decoration: BoxDecoration(
                        color: Colors.transparent,
                        borderRadius: BorderRadius.circular(28.r),
                        border: Border.all(color: MagmaColor.white, width: 2.w),
                      ),
                      child: Center(
                        child: Text('Cancel').blackHanSans(
                          fontSize: 20.sp,
                          color: MagmaColor.black,
                          fontWeight: FontWeight.w700,
                        ),
                      ),
                    ),
                  ),
                ],
              ),
            ),
          ),

          // 顶部装饰图片（超出对话框）
          Positioned(
            top: -30.w,
            left: 60.w,
            right: 60.w,
            child: Center(
              child: AspectRatio(
                aspectRatio: 134 / 134,
                child: SizedBox(
                  width: 134.w,
                  child: Image.asset(
                    MagmaConstant.joinClubDialogDecoration,
                    fit: BoxFit.contain,
                  ),
                ),
              ),
            ),
          ),
        ],
      ),
    );
  }
}
